using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Utility;
using Entities;
namespace BUS
{
   public class tbTourmoBUS
    {
        public static void Insert(tbTourmo t)
        {
            tbTourmoDAL tDAL = new tbTourmoDAL();
            tDAL.Insert(t);
        }
        public static void Update(tbTourmo t)
        {
            tbTourmoDAL tDAL = new tbTourmoDAL();
            tDAL.Update(t);
        }
        public static void Delete(int iD)
        {
            tbTourmoDAL tDAL = new tbTourmoDAL();
            tDAL.Delete(iD);
        }
        public static tbTourmoCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbTourmoDAL tDAL = new tbTourmoDAL();
            return tDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbTourmoCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbTourmoDAL tDAL = new tbTourmoDAL();
            return tDAL.Get(cri.Criter, 0, 0, tbTourmoCollumn.matourmo.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbTourmo GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbTourmoCollumn.matourmo.ToString(), Condition.EQUAL, iD);
            tbTourmoDAL tDAL = new tbTourmoDAL();
            tbTourmoCollection tColl = tDAL.Get(cri.Criter, 0, 0,tbTourmoCollumn.matourmo.ToString(), OrderDirection.ASC.ToString(), out total);
            if (tColl.Count > 0)
                return tColl[0];
            return null;
        }
        public static tbTourmoCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbTourmoDAL tDAL = new tbTourmoDAL();
            return tDAL.Get(cri.Criter, 1, number,
            tbTourmoCollumn.matourmo.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbTourmoCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbTourmoDAL tDAL = new tbTourmoDAL();
            return tDAL.Get(cri.Criter, 1, number,
            tbTourmoCollumn.matourmo.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
